Skip to content

Conversation

@jeanlaurent
Copy link
Member

Add Files API support for image attachments

Images attached via /attach now use provider-specific Files APIs instead of
embedding base64 data in every message.

Changes:

• Store local file paths in messages instead of immediate base64 conversion
• Anthropic: Upload via Files API (beta), reference by file_id , with caching to
avoid re-uploads
• Gemini: Upload via Files API, reference by URI, with caching
• OpenAI/Bedrock: Convert to base64 at send time (no Files API for chat vision)

Benefits:

• Significantly reduces token usage for Anthropic (file IDs vs ~3000+ tokens per
image)
• Fixes "prompt too long" errors when attaching large images
• Each provider handles images optimally for its API

@jeanlaurent jeanlaurent requested a review from a team as a code owner January 21, 2026 13:36
@krissetto
Copy link
Contributor

https://platform.openai.com/docs/api-reference/files

should be similar in concept to the anthropic process implemented

URL: part.ImageURL.URL,
}))
// Use the image converter which handles file refs, data URLs, and HTTP URLs
if imgBlock := convertImagePart(context.Background(), nil, part.ImageURL); imgBlock != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use a real context here so that we can cancel the operation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants